package com.fhz.mvvm.ui.main;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.fhz.mvvm.ServiceApi;
import com.fhz.mvvm.callback.ApiResponse;
import com.fhz.mvvm.entity.Banner;
import com.fhz.mvvm.entity.GoodsInfo;
import com.fhz.mvvm.entity.GoodsInfoLocal;
import com.fhz.mvvm.util.RetrofitMananger;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;
import io.reactivex.Observable;
import retrofit2.http.Query;

/**
 * 时间:2023/8/17
 *
 * @author Mr.Feng
 * 简述: TODO
 */

@HiltViewModel
public class MainViewModel extends ViewModel {

    @Inject
    public MainRepository mMainRepository;
    @Inject
    public MainViewModel(){

    }

//    public MainViewModel(MainRepository mainRepository) {
//        mMainRepository = mainRepository;
//    }

    public LiveData<ApiResponse<Banner>> getBanner(@Query("type") int type, @Query("page") int page, @Query("pageSize") int pageSize){
        return mMainRepository.getBanner(type, page, pageSize);
    }

    public LiveData<ApiResponse<GoodsInfo>> getGoodsInfo(@Query("page") int page, @Query("pageSize") int pageSize){
        return mMainRepository.getGoodsInfo(page,pageSize);
    }

    public void insertGoodsInfo(GoodsInfoLocal goodsInfoLocal){
         mMainRepository.insertGoodsInfo(goodsInfoLocal);
    }

    public LiveData<List<GoodsInfoLocal>> getAllGoods(){
        return mMainRepository.getAllGoods();
    }

}
